<?php
header('Content-type: text/html');

require_once("../inc/functions.php");
require_once("../class/DBConnection.php");
DBConnection::connect("../config/connection.cfg");
require_once("../inc/dao.php");
require_once("../class/DateFormat.php");

$img_path = "../temp/roster_pic.png";

if(isset($_POST['img'])) {
	draw_roster_picture($img_path);
}

$id_clanku = $_GET['id_clanku'];

$query = getReportAndPlayersCount($id_clanku);
$fetch = MySQL_Fetch_Array($query);
$datum = DateFormat::format($fetch["CAS_UPRAVY"], DF_DDMMYYYYHHMM);
$nadpis = $fetch["NADPIS"];
$popis = $fetch["POPIS"];
$text = $fetch["TEXT"];
$autor = $fetch["autor"];
$id_utkani = $fetch["id_utkani"];
$pocet_hracu = $fetch["pocet_hracu"];

if($id_utkani != "" && $pocet_hracu >= 11 && !isset($_POST['img'])) {
?>
<object class="centered"
	classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
	codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"
	width="500" height="350" id="swf/sestava" align="middle">
	<param name="allowScriptAccess" value="sameDomain" />
	<param name="movie"
		value="<? echo "../swf/sestava.swf?id_utkani=$id_utkani&id_clanku=$id_clanku&export=2"; ?>" />
	<param name="quality" value="high" />
	<param name="bgcolor" value="#FFFFFF" />
	<param name="wmode" value="opaque" />
	<embed src="<? echo "../swf/sestava.swf?id_utkani=$id_utkani&id_clanku=$id_clanku&export=2"; ?>"
		quality="high" wmode="opaque" bgcolor="#FFFFFF" width="500"
		height="350" name="swf/sestava" align="middle"
		allowScriptAccess="sameDomain" type="application/x-shockwave-flash"
		pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>
	<?
} else {
	
//header("Content-Disposition: attachment; filename=\"".$nadpis."\"");

require_once('../inc/pdf_exporter.php');
$pdfCreator = new PDFCreator();
$pdfCreator->makeReportPDF($nadpis, $datum, $autor, $popis, $text, $img_path, isset($_POST['img']));
}


?>